package com.hello.fastboot.test.service;

import com.gitee.huanminabc.fastboot.annotation.container.Service;
import com.gitee.huanminabc.fastboot.common.InitializeBean;
import com.gitee.huanminabc.jlambda_sql.jdbc.JdbcCommand;
import com.gitee.huanminabc.jlambda_sql.warapper.LambdaQueryWrapper;
import com.gitee.huanminabc.jlambda_sql.warapper.LambdaWrapper;
import com.hello.fastboot.test.dao.UserManager;
import com.hello.fastboot.test.entity.UserEntity;
import com.hello.fastboot.test.entity.UsersRoleEntity;
import lombok.Data;

/**
 * 简要描述
 *
 * @Author: huanmin
 * @Date: 2025/4/13 20:41
 * @Version: 1.0
 * @Description: 文件作用详细描述....
 */
@Service
@Data
public class UserService implements InitializeBean {
    private final UserManager userManage;
    public UserEntity getUserById() {
        return userManage.selectById(1);
    }

    public UserEntity getUser() {
        LambdaQueryWrapper<UserEntity> queryWrapper = userManage.createQueryWrapper();
        queryWrapper.EQ(UserEntity::getId, 1);
        return userManage.selectOne(queryWrapper);
    }

    public UserEntity getUserCustom() {
        LambdaWrapper<UserEntity> wrapper = userManage.createWrapper();
        wrapper.SELECT().S_COLUMN().FROM().TABLE().
                INNER_JOIN().TABLE(UsersRoleEntity.class).
                ON().FIELD(UsersRoleEntity::getAccount).EQ().FIELD(UserEntity::getAccount);
        return userManage.selectOne(wrapper);
    }

    @Override
    public void init() {
        System.out.println("UserService-init");
    }
}
